package muse;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public abstract class Frame extends JPanel {
	public static enum MFrame {
		PORTAL("Portal"),			// Home portal
		SPLASH("Splash"), 			// Splash screen
		MAIN("MUSE"),				// MUSE screen
		JOURNAL("Journal"),			// Journal screen
		CUSTOMIZE("Customize"),		// Customization dialog
		FACEBOOK("Facebook"),		// Facebook access (screen or link?)
		MUSEUM("Museum"),			// A log of accomplishments
		HELP("Help"),			// Help screen
                CHARACTERCUSTOMIZE("Character Customize");      //Customize character/muse here
                
		/* The name of the screen.  This will be the text on its button. */
		private String text;
		/* 
		 * @param	text	The name of the Frame.	
		 */
		MFrame(String text) {
			this.text = text;
		}
		/*
		 * Gets the name of the Frame.
		 * 
		 * @return	The name of the Frame.
		 */
		public String getText() {
			return text;
		}
	}
	
	/*
	 * The MouseListener that handles activating/deactivating 
	 * the navigator.
	 */
	private static MouseListener blueBeadListener;
	static {
		blueBeadListener = new MouseListener() {
			public void mouseClicked(MouseEvent e) {}
			public void mouseEntered(MouseEvent e) {}
			public void mouseExited(MouseEvent e) {}
			public void mouseReleased(MouseEvent e) {}
			public void mousePressed(MouseEvent e) {
				/* Check if it's a double click.  If not, return. */
				if(e.getClickCount() != 2)
					return;
				// JOptionPane.showMessageDialog(null, "Double click!");
				/* Toggle the Navigator in the app's main Window. */
				Launcher.getWindow().toggleNavi();
			}
		};
	}
	
	private JLayeredPane pane;
	
	public Frame() {
		pane = new JLayeredPane() {
			public Dimension getPreferredSize() {
				return new Dimension(320,480);
			}
		};
		add(pane);
		
		/* Add the doubleclick listener */
		addMouseListener(blueBeadListener);
	}
	/*
	 * Adds a new Layer to the layeredpane.
	 * 
	 * @param	panel	The JPanel to add.
	 * @param	layer	The layer to place panel on.
	 */
	public void addLayer(JPanel panel, int layer) {
		pane.add(panel, new Integer(layer));
	}
	
	/*
	 * Start up anything that should only be running when the
	 * Frame is active. 
	 */
	public void init() {
		/* Set the bounds so that the Frame fills the window. */
		setBounds(Launcher.getWindow().getBounds());
	}
	
	/*
	 * Stops anything that shouldn't be running while the Frame isn't
	 * active.  Probably just freeze any animations and kill any special
	 * sounds.   
	 */
	public void freeze() {}
	
	/*
	 * Draws the (static) background graphic.
	 * 
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
	 */
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.drawImage(new ImageIcon(getClass().getClassLoader().getResource("muse/resources/BGTest.png")).getImage(), 0, 0, null);
	}
}
